/*
 * @Author: 一路向阳 tt_sunzhenfeng@163.com
 * @Date: 2024-02-22 14:25:23
 * @LastEditors: 一路向阳 tt_sunzhenfeng@163.com
 * @LastEditTime: 2024-02-22 14:29:03
 * @FilePath: \utils_ts\21.类的继承.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
export {};

class Person {
  myName: string;

  constructor(name: string) {
    this.myName = name;
  }

  getName() {
    return this.myName;
  }
};

class Male extends Person {
  age: number;

  constructor(name: string, age: number) {
    // 调用回父类的constructor，并把参数传进去
    super(name);
    this.age = age;
  }

  // 重写
  getName() {
    return this.myName + ' ' + this.age;
  }
}

let m = new Male('Jack', 18);
console.log(m.getName());
console.log(m.age);
console.log(m.myName);

